package com.ys.peony.ui.widget;

import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.ys.peony.R;
import com.ys.peony.base.BaseActivity;
import com.ys.peony.base.contract.BasicActivity;


/**
 * Created by Administrator on 2017/4/26.
 */

public class SimpleTitleLayout extends RelativeLayout {
    private TextView title;
    public SimpleTitleLayout(Context context) {
        super(context);
    }

    public SimpleTitleLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        init(context,attrs);
    }

    public SimpleTitleLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        init(context,attrs);
    }
    private void init(Context context,AttributeSet attrs) {
        LayoutInflater.from(context).inflate(R.layout.view_titleview ,this);
        title = findViewById(R.id.title);
        RelativeLayout titleback = findViewById(R.id.titleback);
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MyPage);
        title.setText(a.getString(R.styleable.MyPage_title));
        titleback.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View v) {
                ((BaseActivity)getContext()).hideInput();
                ((Activity)getContext()).finish();
            }
        });
        a.recycle();
    }
    public void setTitle(String s) {
        title.setText(s);
    }
}
